package com.example.administrator.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;

import java.util.ArrayList;
import java.util.List;

public class GridViewActivity extends AppCompatActivity {

    GridView gridView;
    List<People> list = new ArrayList<>();

    int[] images = {R.mipmap.book_1,R.mipmap.book_2,R.mipmap.book_3,R.mipmap.book_4,R.mipmap.book_5};
    String[] titles = {"1111","2222","3333","4444","5555"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_grid_view);
        gridView = (GridView)findViewById(R.id.gridView);
        for (int i=0;i<images.length;i++){
            People people = new People();
            people.setImg(images[i]);
            people.setTitle(titles[i]);
            list.add(people);
        }

        MyGridViewAdapter myGridViewAdapter = new MyGridViewAdapter(GridViewActivity.this,list);
        gridView.setAdapter(myGridViewAdapter);
    }
}
